initrd: Support ztd-compressed modules
authorRichard W.M. Jones <rjones@redhat.com>
Thu, 5 Aug 2021 07:16:28 +0000 (08:16 +0100)
committerdgit client-side .dsc importer <dgit@packages.debian.invalid>
Wed, 12 Nov 2025 21:40:38 +0000 (22:40 +0100)
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1990209
Gbp-Pq: Name 0005-initrd-Support-ztd-compressed-modules.patch

README
configure.ac
src/config.ml.in
src/format_ext2_initrd.ml

diff --git a/README b/README
index e5187a65ed47e21b5a060a86cfe138a9b34a63ea..ccd6f969f5d8ed72496487dd5f11673089ce60b9 100644 (file)
--- a/README
+++ b/README
@@ -102,6 +102,8 @@ are building:
 
   xzcat (command) - if your kernel uses xz-compressed modules
 
+  zstdcat (command) - if your kernel uses zstd-compressed modules
+
 Building and installing
 -----------------------
 
index 5202f4c799e79e5b980b48d87a5651c28fe447b8..e9529dea89bdbe64a277117e6c8bf77d75ed4ef8 100644 (file)
@@ -157,6 +157,9 @@ AC_PATH_PROG(ZCAT,[zcat],[no])
 dnl Check for xzcat, only needed if you have xz-compressed kernel modules.
 AC_PATH_PROG(XZCAT,[xzcat],[no])
 
+dnl Check for zstdcat, only needed if you have zstd-compressed kernel modules.
+AC_PATH_PROG(ZSTDCAT,[zstdcat],[no])
+
 dnl mke2fs.
 AC_PATH_PROG([MKE2FS],[mke2fs],[no],
              [$PATH$PATH_SEPARATOR/sbin$PATH_SEPARATOR])
index 313d6e6dbc30be5b1bd701cf927e611b8c5c2901..b0953dc2d986d7f47d5854212e47638a90b371c4 100644 (file)
@@ -39,6 +39,7 @@ let urpmi = "@URPMI@"
 let yumdownloader = "@YUMDOWNLOADER@"
 let xzcat = "@XZCAT@"
 let zcat = "@ZCAT@"
+let zstdcat = "@ZSTDCAT@"
 let zypper = "@ZYPPER@"
 
 let mke2fs = "@MKE2FS@"
index 6268442ee37e222356d3eafb6cb2199c378b60e1..98d2692e4c15b8d472d20389d944d0c3224be483 100644 (file)
@@ -106,12 +106,24 @@ let rec build_initrd debug tmpdir modpath initrd =
           visit deps;
 
           (* Copy module to the init directory.
-           * Uncompress the module, if the name ends in .xz or .gz.
+           * Uncompress the module, if the name ends in .zst, .xz or .gz.
            *)
           let basename = Filename.basename modl in
           let basename =
             let len = String.length basename in
-            if Config.xzcat <> "no" &&
+            if Config.zstdcat <> "no" &&
+                 Filename.check_suffix basename ".zst"
+            then (
+              let basename = String.sub basename 0 (len-4) in
+              let cmd = sprintf "%s %s > %s"
+                                (quote Config.zstdcat)
+                                (quote (modpath // modl))
+                                (quote (initdir // basename)) in
+              if debug >= 2 then printf "supermin: %s\n" cmd;
+              run_command cmd;
+              basename
+            )
+            else if Config.xzcat <> "no" &&
                  Filename.check_suffix basename ".xz"
             then (
               let basename = String.sub basename 0 (len-3) in